<?php

Yii::import('common.models._base.BaseClassEarlyDiscount');

class ClassEarlyDiscount extends BaseClassEarlyDiscount {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public $MaxdicountAmount;
    public $MaxdicountPercxentage;

    public static function findMaxDscountByClass($classId) {
        $criteria = new CDbCriteria;
        $criteria->select = 'Max(discount_price) as MaxdicountAmount,Max(in_percentage) as MaxdicountPercxentage';
        $criteria->condition = 'classes_id=' . $classId;
        $maxPrice = ClassEarlyDiscount::model()->find($criteria);       
            if ($maxPrice['MaxdicountAmount'] != '' && $maxPrice['MaxdicountPercxentage'] != '') {
                return('Upto' . $maxPrice['MaxdicountAmount'] >= $maxPrice['MaxdicountPercxentage']) ? '<span style=" font-size: 14px; "><img src="' . ThemePath(true) . '/images/rupees.png"></span> ' . number_format($maxPrice['MaxdicountAmount'], 2) : number_format($maxPrice['MaxdicountPercxentage'], 2) . ' % Discount';
            }else{
                return 'No Discount';
        }
    }

}
